<template>
  <div>
    <div class="tb">
      <p>欢迎光临_vue开发的收银系统_水果店</p>
      <table border="1">
      <tbody>
        <tr><td><b>苹果{{price}}￥/斤，折扣&lt;{{discount}}折&gt;</b></td></tr>
        <tr><td>请输入你需要购买的斤数<input type="number" v-model="num"></td></tr>
        <tr><td><button @click="check_out">结账买单~</button></td></tr>
        <tr><td>结账单：总价：{{price_z}}￥元 折后价：{{price_d}}￥元 省了：{{price_s}}￥元</td></tr>
      </tbody>
    </table>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      price: 10,
      discount: 8,
      price_z: 0,
      price_d: 0,
      price_s: 0,
      num: 0
    }
  },

  created () {

  },

  methods: {
    check_out () {
      this.price_z = this.price * this.num
      this.price_d = this.price * this.num * this.discount / 10
      this.price_s = this.price_z - this.price_d
    }
  }
}
</script>

<style scoped lang='less'>
  .tb{
    text-align: center;
    width: 600px;
    margin: 50px auto 0;
    table {
      width: 100%;
    }
    p {
      margin: 0;
    }
  }
</style>
